//对api接口进行统一管理
import requests from "./request";

import cookie from "js-cookie";

let token = cookie.get("token");


export default {
    //分页查看用户信息
    getUserInfoPages(current, size, searchObj) {
        return requests({
            url: `bcra/personalInfo/list/${current}/${size}`,
            method: "post",
            data: searchObj
        })
    },
    getUserInfo(id) {
        return requests({
            url: `bcra/personalInfo/find/${id}`,
            method: "get",
        })
    },
    //删除用户
    deleteUserInfo(id) {
        return requests({
            url: `bcra/personalInfo/delete/${id}`,
            method: "delete",
        })
    },
    //修改用户
    updateUserInfo(body) {
        return requests({
            url: `bcra/personalInfo/update`,
            method: "post",
            data: body
        })
    },
    //批量删除问卷
    deleteBatchUserInfo(ids) {
        return requests({
            url: `bcra/personalInfo/batchDelete`,
            method: "delete",
            data: ids
        })
    },
    //冻结用户
    frozenUser(id) {
        return requests({
            url: `bcra/personalInfo/frozen/${id}`,
            method: "post",
        })
    },
    //查询已经注册的手机号
    findPhone() {
        return requests({
            url: `bcra/personalInfo/findPhone`,
            method: "get",
        })
    },
    //用户登录
    login(phone, password) {
        return requests({
            url: `bcra/personalInfo/login/${phone}/${password}`,
            method: "get",
        })
    },
    //用户通过短信登录
    loginBySms(phone) {
        return requests({
            url: `bcra/personalInfo/loginBySms/${phone}`,
            method: "get",
        })
    },
    //获取二维码
    getQrCode() {
        return requests({
            url: `sso/wechat/getLoginParam`,
            method: "get",
        })
    },
    //用户注册
    register(body) {
        return requests({
            url: `bcra/personalInfo/creatNew`,
            method: "post",
            data: body
        })
    },
    //导出用户数据
    exportExcel(body) {
        return requests({
            url: `bcra/personalInfo/exportExcel`,
            method: "post",
            responseType: "blob",
            data: body,
        })
    },
    //token令牌检验
    checkToken() {
        return requests({
            url: `bcra/personalInfo/checkToken`,
            method: "get",
            headers: {
                token: token
            }
        })
    }
}